<?
require_once('../mod_config.php');
require_once('../playlist/config.php');
require_once('../category/config.php');
$moduol_name = 'Video';
$array_all_cat = array();
$array_all_per = array();
$array_all_pla = array();
$array_vid = array();

$array_all_cat = Cate::getListCat();
$count_cat = count($array_all_cat);

/*------------------ GET ALL PERSON --------------------------*/
$db_query = new db_query(' SELECT per_id,per_name
                           FROM person');
$array_all_per = $db_query->resultArray();
$count_per = count($array_all_per);

/*------------------ GET ALL PLAYLIST ---------------------*/
$array_all_pla = Playlist::getListPla();
$count_pla = count($array_all_pla);
/*-------------------- Class video -----------------------*/
class video{
   var $total = 0;
   /**
    * getListVideo
    * @param int $limit So luong ban ghi tra ve
    * @param int $start Vi tri ban ghi bat dau lay
    * @return array  Mang cac video
   */
   public function getListVideo($start=0,$limit){
      $array_vid = array();
      $limit = ($limit > 0) ? $limit : 20;
      $db_query = new db_query($sql =' SELECT   
                                    vid_id,
                                    vid_id_youtube,
                                    vid_name,
                                    cat_id,
                                    pla_id,
                                    vid_lyric,
                                    vid_duration,
                                    vid_view,
                                    vid_image,
                                    vid_date,
                                    vid_active,
                                    vid_hot
                                 FROM 
                                    video
                                 ORDER BY 
                                    vid_id DESC
                                 LIMIT '. $start . "," . $limit);
      $array_vid = $db_query->resultArray();
      unset($db_query);
      return $array_vid;
   }
   
   /**
    * getTotalVideo
    * @return int Tong so video co trong bang 
   */
   public function getTotalVideo(){
      $count = 0;
      $db_count = new db_query("SELECT count(vid_id) as count FROM video"); 
      $row = mysql_fetch_assoc($db_count->result);
      $count = (isset($row['count'])) ? $row['count'] : $count;
      return $count;
   }
   
   
}
$video = new video;               
?>